<?php
    include('./config.php');
    include('./request.php');
    $username = $result->username;
    $password = $result->password;
    $phone = $result->phone;
    $email = $result->email;
    try{
        $pdo = new PDO($dsn,$user,$pass);
        $sql1 = "select user_name from user where user_name='".$username."';";
        $result = $pdo->prepare($sql1);
        $result->execute();
        $arr = $result->fetchAll();
        if($arr['user_name']==$username){
            echo "用户已经存在";
        }else{
            $sql = "insert into user(user_name,user_password,user_phone,user_email)values('".$username."','".$password."','".$phone."','".$email."');";
            $res = $pdo->prepare($sql);
            $res->execute();
            if($res){
                echo "ok";
            }else{
                echo "error";
        }
    }
    }catch(PDOException $e){
        echo "error";
    }

?>